Skip to main content

All Questions

Tagged with
0votes
3answers
196views

How to edit a string matching a pattern in a specific field on the condition another string is not present on the same line

I need to edit the string "NA" to "Na" only if it is in the 6th field of a file. I can currently achieve this with: awk '{gsub("NA","Na",$6)}1' $filename ...
CPC_92's user avatar
1vote
2answers
6kviews

split string using a substring as delimiter and get the later part

Here is my string LIBRARY_TRGT_CANV,CANV_MATCH<anything> I wish to get all the text after last occurance of our delimiter which is _TRGT_: Desired output: CANV,CANV_MATCH<anything> ------ ...
Ashar's user avatar
0votes
1answer
123views

Need help Formatting a file having key: value [duplicate]

I have a file having the below values: cat data.txt server1: 'calv' server2: 'anot' log: '/u/log/1' server3: 'calv' server4: 'anot' server5: 'secd' server6: 'calv' LIB_TRGT_calv,anot: '/tmp/hello.txt' ...
Ashar's user avatar
-1votes
5answers
883views

How to make sure that the last character of each line of a file ends with single quote character

I have a file which has several lines. I wish to update the file while making sure that the last visible character of each line of the file is a single quote '. In case not, then we should add the ...
Ashar's user avatar
0votes
1answer
1kviews

How to add single quote at the end of ONLY the last line of a file [duplicate]

I want a non-perl solution where I should be able to append a single quote ' at the last visible (non-escape characters) line of a file and save it back to the file. cat example.txt var1: 'funn' var2: ...
Ashar's user avatar
1vote
2answers
966views

Remove duplicates of specific line keeping only the first appearance of each without touching other unspecified duplicates

I'm trying to edit a text file containing several duplicates. The goal is to keep only the first match of a string and remove the rest duplicate lines of the same string. In the example file * Title 1 ...
yeyin33455's user avatar
-1votes
4answers
1kviews

Shell-script extract value pair with sed/awk?

Given a string like this: NAME="bla" TYPE="test" SIZE="10" I want to get the values for each pair into into separate shell-script vars. So, for example, say we have ...
Kyu96's user avatar
1vote
3answers
107views

Vary positions in a string to generate a list of outputs

I am dealing with short strings (they're DNA sequences) of ~30 length. For my purposes, every 5th position needs to be swapped for any of the 4 DNA bases (A, C, T, G). e.g. if I have an input of ...
catchprj's user avatar
1vote
1answer
271views

How to get string between starting with X to ending with Y using Shell

I have dynamic string which are mentioned below, where I want to get ABCXXX.XXX.XXX string till , character. Starting character is fix (ABC)CAPITAL ONLY and ending also fix com or Xcom. String can be ...
Nullpointer's user avatar
0votes
1answer
113views

Print Multiple Substrings Including an IP Address

Good day! I have a giant input file that displays a lot of garbage and I would like to export multiple substrings. The problem is that sometimes additional information is injected into the file making ...
DD-Nerd's user avatar
0votes
1answer
725views

How to execute multiple commands from an input file and string it to a new output file

I want to execute multiple commands (one after the other) from an input.txt file and output it to a new .csv file. All the commands run successfully when executed individually, but nothing happens ...
gbi_gbi's user avatar
0votes
1answer
218views

Extracting multiple strings, according to a pattern, in a bash script

I'm writing a shell script to generate a directory listing. as an input a receive a long html string : https://www.mycompany.com/posts/aureliaflore_china-seoul-startup-activity-6571925510337728512-...
magique's user avatar
1vote
1answer
63views

Replacing lines in one file based of indices in a second file

I have two files: Ref.txt which contains: ABCDEFG,15147,1,2,6 HIJKLMN,500,3,4 and Seq.txt which contains: ABCXXXX ABCDEXX IIJKXXX HIHKXXX LMNOPQR BBCDEXX STUVWXY I would like to replace the certain ...
DNA_bash's user avatar
0votes
4answers
828views

Removing lines whose first column is duplicated

I have a file where strings are separated by a special string (not a comma or delimiter) e.g. <vvv>. I want to check if all strings in the first field are unique. If duplicate rows for the same ...
user9371654's user avatar
1vote
3answers
2kviews

Append strings to multiple space-separated values in a variable

I have a variable VAR="XYZ YZA ZAB" declared and I would like to append some strings next to all the words in that variable. For example: I want to append .file1 to each space-separate substring in ...
sabarish jackson's user avatar

153050per page
close